<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
	</body>
</html>
<script type="text/javascript">
	// 异步编程
	// 1s后控制台输出111，2s后输出222，3s后输出333
	// 只使用setTimeout会形成回调地狱
	function one(){
		setTimeout(() => {
			console.log('1');
			iterator.next();
		},1000)
	}
	function two(){
		setTimeout(() => {
			console.log('2');
			iterator.next();
		},2000)
	}
	function three(){
		setTimeout(() => {
			console.log('3');
		},3000)
	}
	function * fn(){
		yield one();
		yield two();
		yield three();
	} 
	let iterator = fn();
	iterator.next();
</script>
